package com.abei.gas.controller;


import cn.hutool.core.util.StrUtil;
import com.abei.gas.entity.Inorder;
import com.abei.gas.entity.Outorder;
import com.abei.gas.service.OutorderService;
import com.abei.gas.vo.DataVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/outorder")
@Api(tags = "出库管理相关接口")
public class OutorderController {
    @Autowired
    private OutorderService outorderService;

    @PostMapping("/stockOut")
    public DataVo stockOut(@RequestBody Outorder outorder){
        return outorderService.stockOut(outorder);
    }

    @PostMapping("/insert")
    public DataVo insert(@RequestBody Outorder outorder){
        outorderService.save(outorder);
        return DataVo.success();
    }

    @RequestMapping("/deleteById")
    public void deleteById(HttpServletRequest request){
        String id = request.getParameter("id");
        outorderService.deleteById(id);
    }

    @PostMapping("/update")
    public DataVo update (@RequestBody Outorder outorder){
        outorderService.updateById(outorder);
        return DataVo.success();
    }

    @GetMapping("/findAll")
    public DataVo<Outorder> findAll(Integer page, Integer limit){
        return outorderService.findAll(page,limit);
    }

    @GetMapping("/selectById")
    public DataVo<Outorder> selectById(HttpServletRequest request) {
        String id = request.getParameter("id");
        return outorderService.findById(id);
    }
}
